#ifndef __RC_H__
#define __RC_H__

#ifdef __cplusplus
extern "C" {
#endif

#include "crc16.h"
#include "que.h"

/* ----------------------- RC Channel Value Definition---------------------------- */
#define CH_MIN                 ((int16_t)364   ) 
#define CH_MID               ((int16_t)1024  ) 
#define CH_MAX                 ((int16_t)1684  )  
#define CH_OFF                 ((int16_t)660   )  
/* ----------------------- RC Switch Value Definition----------------------------- */
#define SW_UP                    ((int8_t)1      ) 
#define SW_MD                    ((int8_t)3      ) 
#define SW_DN                    ((int8_t)2      )  
/* ----------------------- PC Mouse Value Definition-------------------------------- */
#define MS_MIN                 ((int16_t)-32768 ) 
#define MS_MID                   ((int16_t)0      ) 
#define MS_MAX                 ((int16_t)32767  ) 
#define MS_UP                  ((int8_t)0      ) 
#define MS_DN                  ((int8_t)1      ) 
/* ----------------------- PC Key Value Definition-------------------------------- */
#define KEY_W                ((uint8_t)0x01<<0) 
#define KEY_S                ((uint8_t)0x01<<1) 
#define KEY_A                ((uint8_t)0x01<<2) 
#define KEY_D                ((uint8_t)0x01<<3)
#define KEY_SHIFT              ((uint8_t)0x01<<4) 
#define KEY_CTRL               ((uint8_t)0x01<<5)
#define KEY_Q                  ((uint8_t)0x01<<6) 
#define KEY_E                ((uint8_t)0x01<<7)

#define RC_HEADER         0xaa    //帧头
#define RC_INIT_CRC16 0x6789  //CRC16数据校验初始值
#define RC_FRAME_SIZE       9     //帧大小

typedef struct RC
{
  int16_t ch0;
  int16_t ch1;
  int16_t ch2;
  int16_t ch3;
  int8_t  s1;
  int8_t  s2;
}RC; // remote control

uint8_t RC_CheckFrame(uint8_t* buf);
void RC_Decode(RC* rc, uint8_t* buf);
uint8_t RC_Pop(RC* rc, Que* que);

#ifdef __cplusplus
}
#endif

#endif

